package com.ChenYaRou.www.dao.impl;


import com.ChenYaRou.www.dao.OrdersDao;
import com.ChenYaRou.www.po.Orders;
import com.ChenYaRou.www.utils.GenerateSql;
import com.ChenYaRou.www.utils.JdbcUtil;

import java.sql.SQLException;
import java.util.List;

/**
 * @ClassName OrdersDaoImpl
 * @Description TODO
 * @Author 86183
 * @Date 2022/4/12 0:37
 * @Version 1.0
 **/
public class OrdersDaoImpl implements OrdersDao {

    /**
     * 更新订单
     * @param  newOrder
     * @param  oldOrder
     * @return 成功与否
     * @throws IllegalAccessException
     * @throws SQLException
     */
    @Override
    public int update(Orders newOrder,Orders oldOrder) throws IllegalAccessException, SQLException {
       return JdbcUtil.getInstance().insertOrUpdate(GenerateSql.getInstance().update(newOrder,oldOrder));
    }

    /**
     * 增加订单
     * @param  orders
     * @return 成功与否
     */
    @Override
    public int insert(Orders orders) throws IllegalAccessException, SQLException {
        return JdbcUtil.getInstance().insertOrUpdate(GenerateSql.getInstance().insert(orders));
    }

    /**
     * 查找orders集合
     * @param orders 条件orders
     * @return
     * @throws IllegalAccessException
     * @throws SQLException
     * @throws NoSuchFieldException
     * @throws InstantiationException
     */
    @Override
    public List<Orders> selectMore(Orders orders) throws IllegalAccessException,
            SQLException, NoSuchFieldException, InstantiationException {
        return JdbcUtil.getInstance().selectMore(GenerateSql.getInstance().select(orders), Orders.class);
    }
}
